// WebPage.h: interface for the CWebPage class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WEBPAGE_H__13EE3E62_D1FA_4C3C_AD3B_AA93B44A638D__INCLUDED_)
#define AFX_WEBPAGE_H__13EE3E62_D1FA_4C3C_AD3B_AA93B44A638D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "WebFile.h"

const COLORREF crBlack = RGB( 0x00, 0x00, 0x00 );
const COLORREF crWhite = RGB( 0xFF, 0xFF, 0xFF );

class CWebPage : public CWebFile
{
public:
	CWebPage();
	virtual ~CWebPage();

	virtual bool IsDirty() const;
	virtual void SetDirty( bool bDirty );
	virtual void ResetContent();

	virtual bool GetFileContents( LPCSTR* ppszContentType, void** ppFileContents, UINT* pnFileSize ) const;
	virtual const CString& GetFileContents() const;

protected:
	enum HORIZONTAL_ALIGNMENT
	{
		haDefault,
		haLeft,
		haRight,
		haCenter,
		haJustify,
	};

	enum VERTICAL_ALIGNMENT
	{
		vaDefault,
		vaTop,
		vaMiddle,
		vaBaseline,
		vaBottom,
	};

	virtual void GenerateContent() = 0;

	virtual void BeginDocument();
	virtual void EndDocument();
	virtual void BeginHead();
	virtual void EndHead();
	virtual void BeginTitle();
	virtual void EndTitle();
	virtual void BeginBody();
	virtual void EndBody();
	virtual void BeginHeading( int nType, HORIZONTAL_ALIGNMENT ha = haDefault );
	virtual void EndHeading( int nType );
	virtual void BeginTable( int nWidth = -1, bool bWidthIsPercent = false, int nCellSpacing = -1, HORIZONTAL_ALIGNMENT ha = haDefault, VERTICAL_ALIGNMENT va = vaDefault );

	void BeginTable( HORIZONTAL_ALIGNMENT ha, VERTICAL_ALIGNMENT va = vaDefault )
	{
		BeginTable( -1, false, -1, ha, va);
	}

	virtual void EndTable();
	virtual void BeginRow();
	virtual void EndRow();
	virtual void BeginColumn( int nWidth, bool bWidthIsPercent, int nHeight, bool bHeightIsPercent, HORIZONTAL_ALIGNMENT ha, VERTICAL_ALIGNMENT va, int nColSpan, COLORREF crBackground );
	
	void BeginColumn()
	{
		BeginColumn( -1, false, -1, false, haDefault, vaDefault, -1, crWhite );
	}

	void BeginColumn( COLORREF crBackground )
	{
		BeginColumn( -1, false, -1, false, haDefault, vaDefault, -1, crBackground );
	}

	void BeginColumn( int nWidth, bool bWidthIsPercent = false, HORIZONTAL_ALIGNMENT ha = haDefault )
	{
		BeginColumn( nWidth, bWidthIsPercent, -1, false, ha, vaDefault, -1, crWhite );
	}

	void BeginColumn( HORIZONTAL_ALIGNMENT ha, VERTICAL_ALIGNMENT va = vaDefault, int nColSpan = -1, COLORREF crBackground = crWhite )
	{
		BeginColumn( -1, false, -1, false, ha, va, nColSpan, crBackground );
	}

	void BeginColumn( HORIZONTAL_ALIGNMENT ha, int nColSpan, COLORREF crBackground = crWhite )
	{
		BeginColumn( -1, false, -1, false, ha, vaDefault, nColSpan, crBackground );
	}

	void BeginColumn( HORIZONTAL_ALIGNMENT ha, COLORREF crBackground )
	{
		BeginColumn( -1, false, -1, false, ha, vaDefault, -1, crBackground );
	}

	void BeginColumn( int nHeight, int nColSpan, COLORREF crBackground = crBlack )
	{
		BeginColumn( -1, false, nHeight, false, haDefault, vaDefault, nColSpan, crBackground );
	}

	void BeginColumn( int nHeight, COLORREF crBackground )
	{
		BeginColumn( -1, false, nHeight, false, haDefault, vaDefault, -1, crBackground );
	}

	virtual void EndColumn();
	virtual void BeginAnchor( LPCTSTR szHREF );
	virtual void EndAnchor();
	virtual void BeginParagraph( HORIZONTAL_ALIGNMENT ha = haDefault );
	virtual void EndParagraph();
	virtual void BeginFont( COLORREF crText );
	virtual void EndFont();
	virtual void BeginBold();
	virtual void EndBold();
	virtual void InsertContent( LPCTSTR szText );
	virtual void InsertContent( double d, int nDecimalPlaces );
	virtual void InsertContent( int n );
	virtual void InsertContent( UINT n );
	virtual void InsertContent( DWORD n );
	virtual void InsertContent( __int64 n );

private:
	void InsertNumberString( TCHAR* p, int nLength );
	void InsertAlignmentTag( HORIZONTAL_ALIGNMENT ha );
	void InsertAlignmentTag( VERTICAL_ALIGNMENT va );
	void InsertColorTag( LPCTSTR szTagName, COLORREF cr );

	bool m_bDirty;
	CString m_strFileContents;
};

#endif // !defined(AFX_WEBPAGE_H__13EE3E62_D1FA_4C3C_AD3B_AA93B44A638D__INCLUDED_)
